import Vue from 'vue'
import VueRouter from 'vue-router'

import VedioCom from '../views/vedio/VedioCom.vue'

Vue.use(VueRouter)

const routes = [
 
  {
    path: '/',
    name: 'root',
    // component:()=>import(/* webpackChunkName: "about" */ '../views/home/MyMovie.vue')
    
    redirect: '/movies'
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
   
  }, 
  {
    path:'/movies',
    component:()=>import(/* webpackChunkName: "about" */ '../views/home/MyMovie.vue'),
    redirect: 'movies/show_movies',
      children:[
        {
          path:"show_movies",
          component:()=>import(/* webpackChunkName: "about" */ '../views/home/items/movies.vue'),
         
        },
        {
          path:"cinema",
          name:"cinema",
          component:()=>import(/* webpackChunkName: "about" */ '../views/home/items/cinema.vue')
        },
        {
          path:"preper",
          name:"preper",
          component:()=>import(/* webpackChunkName: "about" */ '../views/home/items/preper_show.vue')
        },
        {
          path:"classical",
          name:"classical",
          component:()=>import(/* webpackChunkName: "about" */ '../views/home/items/classical_files.vue')
        },
       
        
      ]
  },
  
   
  {
    path: '/vedio',
    name: 'vedio',
    component: () => import(/* webpackChunkName: "about" */ '../views/MyVideo.vue'),
    children:[
      {
        path:'commond',
        name:'commond',
        component:VedioCom
      },
      {
        path:'predict',
        name:'predict',
        component: ()=>import(/* webpackChunkName: "about" */ '../views/vedio/VedioCom2.vue')
      },
      {
        path:'hotjiedu',
        name:'hotjiedu',
        component: ()=>import(/* webpackChunkName: "about" */ '../views/vedio/VedioCom3.vue')
      },
      {
        path:'saymovie',
        name:'saymovie',
        component: ()=>import(/* webpackChunkName: "about" */ '../views/vedio/VedioCom4.vue')
      },
      {
        path:'entertainment',
        name:'entertainment',
        component: ()=>import(/* webpackChunkName: "about" */ '../views/vedio/VedioCom5.vue')
      },
      
    
    ]
  },
  {
    path: '/minivedio',
    name: 'minivedio',
    component: () => import(/* webpackChunkName: "about" */ '../views/MiniVideo.vue')
  },
  {
    path: '/show',
    name: 'show',
    component: () => import(/* webpackChunkName: "about" */ '../views/MyShow.vue')
  },
  {
    path: '/mine',
    name: 'mine',
    component: () => import(/* webpackChunkName: "about" */ '../views/MyInfo.vue')
  },
  {
    path: '/city',
    name: 'city',
    component: () => import(/* webpackChunkName: "about" */ '../views/home/citylist/CityList.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "about" */ '../views/login/MyLogin.vue')
  },

  {
    path:'/show_movies_item',
    name:"movies_item",
    component:()=>(/* webpackChunkName: "about" */ '../views/home/items/MoviesItem.vue')
  },
  
 
  {
    path:"*",
    name:'404page',
    component:() => import(/* webpackChunkName: "about" */ '../views/all/ErrorPage.vue')
  }

]

const router = new VueRouter({
  routes
})

router.beforeEach((to,from, next)=>{
  if(to.path == '/mine'){
    if(localStorage.getItem('user')){
      next();
    }else{
      next('/login');
    }
  }else{
    // 放行
    next()
  }
})

export default router
